/**
 * Copyright Dinglian. All Rights Reserved.
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.lyh.provider.controller;

/**
 * 限流操作
 *
 * @author LinYeHui
 * @date 2022/5/26
 * @company Dinglian
 */
import com.lyh.provider.sentinel.ResourceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/provider")
public class ProviderSentinelController {
    @GetMapping("/sentinel01")
    public String doSentinel01(){
        return "sentinel test01";
    }

    //测试方法
    @GetMapping("/sentinel02")
    public String doSentinel02(){
        return "sentinel test 02";
    }

    //两个测试方法(相当于两条链路)调用该资源 sentinel ->resource
    @Autowired
    private ResourceService resourceService;
    @GetMapping("/sentinel03")
    public String doSentinel03(){
        resourceService.doGetResource();
        return "sentinel 03 test";
    }

    @GetMapping("/sentinel04")
    public String doSentinel04(){
        resourceService.doGetResource();
        return "sentinel 04 test";
    }

    @GetMapping("/sentinel/sentinel06")
    public String doFindById(@RequestParam("id") Integer id){
        return resourceService.doGetResource(id);
    }
}
